package com.shujia.mllib

import org.wltea.analyzer.core.{IKSegmenter, Lexeme}

import java.io.StringReader
import scala.collection.mutable.ListBuffer

object IKUtil {
  def main(args: Array[String]): Unit = {

    val text = "数加学院今日星范的李湘一家出发到法国巴黎参加秋冬巴黎时装周"

    println(IKUtil.fit(text))
  }

  /**
   * 中午分词工具
   * @param text ：文本
   * @return
   */
  def fit(text: String): List[String] = {

    val listBuffer = new ListBuffer[String]

    val sr = new StringReader(text)
    val ik = new IKSegmenter(sr, true)

    var word: Lexeme = ik.next()
    while (word != null) {

      listBuffer += word.getLexemeText

      word = ik.next()
    }

    listBuffer.toList
  }
}
